<template>
    <div class="mui-numbox" data-numbox-min='1'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <!-- @change表示input中的值发生变化时就会触发这个时间 -->
        <input id="test" class="mui-input-numbox" type="number" :value=" initcount" @change="countChanged"
               ref="numbox"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>


<script>
    import mui from '../../lib/mui/js/mui.js'

    export default {
        mounted() {
            mui(".mui-numbox").numbox();
        },
        methods: {
            //用于监听number组件中购物车数量的改变
            countChanged() {
                //    console.log(this.$refs.numbox.value);
                this.$store.commit("updatecar", {
                    id: this.goodsid,
                    count: this.$refs.numbox.value
                })
            }
        },
        props: ['initcount', 'goodsid']
    }
</script>


<style lang="scss" scoped>

</style>